# -*- coding: utf-8 -*-
# @Author   : Claus
# @Time     : 2020/6/24 10:26
# @FileName : 读取文件的三种方式.py

file_path = "./a.txt"
with open(file_path, "r") as f:
    data = f.read()
print(f"全部数据 --> {data}")
with open(file_path, "r") as f:
    part_data = f.read(12)
print(f"读取12个字节 --> {part_data}")
print("==========================================================")
with open(file_path, "r") as f:
    data = f.readline()
    data2 = f.readline()
    data3 = f.readline()
print(data, end="\t")
print(data2, end="\t")
print(data3, end="\t")
print("")
print("==========================================================")
with open(file_path, "r") as f:
    data = f.readlines()
print(data)

with open(file_path , 'a') as f:
    f.write("hello world\r")